//
//  AppDelegate.m
//  StarPhone
//
//  Created by sxsk on 2025/2/17.
//

#import "AppDelegate.h"
#import "BaseNavigationController.h"
#import "KTDefines.h"
#import "UIColor+Extension.h"
@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window  makeKeyAndVisible];
    self.window.rootViewController = [self createTabBar];
    return YES;
}

#pragma  mark - 创建Tabbar
#pragma mark - 创建Tabbar
- (UITabBarController *)createTabBar {
    UITabBarController *tabVC = [[UITabBarController alloc] init];
    NSArray * controllerArray;
    NSArray * titleArray;
    NSMutableArray * navArray;
    NSArray * imageArray;
    NSArray * seletedImageArray;
    
    //TODO:判断逻辑：如果是业主，即IsLimit=YES，就不用判断单位类型。如果不是业主，在去判断部门类型
    controllerArray = @[@"StarPhoneViewController",@"StarHomeViewController",@"StarControlViewController",@"StarExitViewController"];
    titleArray = @[@"拨打电话",@"首页卫星",@"遥控配置",@"立即退出"];
    navArray = [[NSMutableArray alloc] init];
    imageArray = @[@"phone",@"iocn-1",@"icon-2",@"icon-3"];
    seletedImageArray = @[@"phone",@"iocn-1",@"icon-2",@"icon-3"];
    
    
    for (int i = 0; i < controllerArray.count; i ++) {
        Class class = NSClassFromString(controllerArray[i]);
        UIViewController *controller = [[class alloc] init];
        BaseNavigationController *mainNav = [[BaseNavigationController alloc] initWithRootViewController:controller];
        controller.title = titleArray[i];
        if(@available(iOS 10.0,*)) {
            [[UITabBar appearance] setUnselectedItemTintColor:kColor(@"#BDF2FF")];
        }
        [[UITabBar appearance] setBackgroundColor:kColor(@"#22528F")];
        [[UITabBar appearance] setTranslucent:NO];
        [[UITabBar appearance] setShadowImage:[UIImage new]];
        [[UITabBar appearance] setBackgroundImage:[UIImage new]];
        [[UITabBar appearance] setClipsToBounds:YES];
        [mainNav.tabBarItem setTitleTextAttributes:@{NSFontAttributeName:kFontSystem(12),NSForegroundColorAttributeName:kColor(@"#BDF2FF")} forState:UIControlStateNormal];
        [mainNav.tabBarItem setTitleTextAttributes:@{NSFontAttributeName:kFontSystem(12),NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateSelected];
        mainNav.tabBarItem.image = [[UIImage imageNamed:imageArray[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        mainNav.tabBarItem.selectedImage = [[UIImage imageNamed:seletedImageArray[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [navArray addObject:mainNav];
    }
    tabVC.viewControllers = navArray;
    //tabVC.delegate = self;
    return tabVC;
}

#pragma mark - UISceneSession lifecycle




@end
